package flc.ast.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyStyleBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class StyleAdapter extends StkProviderMultiAdapter<MyStyleBean> {

    public StyleAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(40));
        addItemProvider(new StyleProvider());
    }

    private class StyleProvider extends BaseItemProvider<MyStyleBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_style;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyStyleBean bean) {
            baseViewHolder.setImageResource(R.id.ivStyleItemImg, bean.getImg());
            baseViewHolder.setText(R.id.tvStyleItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.ivStyleItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivStyleItemSel).setVisibility(View.GONE);
            }
        }
    }
}
